#!/usr/bin/perl

# validate command line
(@ARGV >= 4) || die "Usage: link.pl <source dir> <target dir> <bit-pair> <extn>";
($ARGV[2] =~ /(\d+)-(\d+)/) || die "Bit pair is to be specified like normal-mini. For (e.g.) 32-16.";

# assign the command line variables
chdir $ARGV[0];
$dir = `pwd`;
chomp($dir);
$tdir = $ARGV[1];
$nbit = $1;
$mbit = $2;
$extn = $ARGV[3];

# iterate through files and create link
@files = <$dir/*$nbit.$extn>;
foreach(@files){
	/(.*)\/(.*)$nbit\.$extn$/;
	$rc=`ln -sf "$1/$2$nbit.$extn" $tdir/$2.$extn`;
	$rc=`ln -sf "$1/$2$mbit.$extn" $tdir/$2-mini.$extn`;
}

